# We build "concurrent" tests in a separate target to significantly speed up
# linking on platforms which prefer shared libraries (e.g., macos).

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:copts.bzl", "copts")

cc_library(
    name = "concurrent",
    # We've split all of the tests into separate files so they can be
    # compiled in parallel which is significantly faster than having
    # all of the tests in a single file.
    srcs = [
        "concurrent.h",
        "concurrent-with-timer.cc",
        "downstream-done-both-eventuals-success.cc",
        "downstream-done-one-eventual-fail.cc",
        "downstream-done-one-eventual-stop.cc",
        "emit-fail-pipe.cc",
        "emit-interrupt-fail.cc",
        "emit-interrupt-stop.cc",
        "emit-stop-pipe.cc",
        "fail.cc",
        "fail-before-start.cc",
        "fail-or-stop.cc",
        "flat-map.cc",
        "interrupt-fail.cc",
        "interrupt-fail-or-stop.cc",
        "interrupt-stop.cc",
        "interrupt-success.cc",
        "moveable.cc",
        "stop.cc",
        "stop-before-start.cc",
        "stream-fail.cc",
        "stream-stop.cc",
        "success.cc",
    ],
    copts = copts(),
    visibility = ["//test:__pkg__"],
    deps = [
        "//eventuals",
        "//test:promisify-for-test",
        "//test:event-loop-test",
        "@com_github_google_googletest//:gtest",
        "@com_github_google_googletest//:gtest_main",
    ] + select(
        {
            # We support backward lib only for Linux.
            # The support for Windows and MacOS might be added in future.
            # https://github.com/3rdparty/eventuals/issues/450
            # https://github.com/3rdparty/eventuals/issues/616
            "@platforms//os:linux": [
                "@com_github_3rdparty_bazel_rules_backward_cpp_stacktrace//:backward-stacktrace",
            ],
            "//conditions:default": [],
        },
    ),
    # Setting it to False or leaving it absent will prevent concurrent
    # tests from running on Windows.
    alwayslink = True,
)
